package com.hashbee.bbs.controller;

import com.hashbee.bbs.bo.PageTags;
import com.hashbee.bbs.bo.para.PageQueryPara;
import com.hashbee.bbs.service.TagService;
import com.hashbee.bo.ReturnData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/bbs/tags")
public class TagsController {

    private static final Logger logger = LoggerFactory.getLogger(TagsController.class);

    @Autowired
    private TagService tagService;

    @GetMapping("/page")
    public ReturnData page(@RequestParam(value = "pageIndex", required = false, defaultValue = "0") Integer pageIndex,
                           @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {

        ReturnData<PageTags> returnData = new ReturnData<>();
        PageQueryPara pageQueryPara = new PageQueryPara();
        pageQueryPara.setPageIndex(pageIndex);
        pageQueryPara.setPageSize(pageSize);
        returnData.setData(tagService.queryPage(pageQueryPara));

        return returnData;
    }
}
